<?php

namespace app\admin\model\game;

use think\Model;


class Pvp extends Model
{

    

    // 表名
    protected $name = 'game_pvp';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'sex_text',
        'num_text',
        'type_text',
        'magic_name'
    ];

    
    public function getSexList()
    {
        return ['man' => __('Man'), 'woman' => __('Woman')];
    }     

    public function getNumList()
    {
        return ['single' => __('Single'), 'double' => __('Double')];
    }     

    public function getTypeList()
    {
        return ['close' => __('Close'), 'far' => __('Far')];
    }


    public function getSexTextAttr($value,$data)
    {
        switch ( $data['sex'] ){
            case 'woman':
                return '女';
                break;
            case 'man':
                return '男';
                break;
        }
    }
    public function getMagicNameAttr($value,$data)
    {
        switch ( $data['magic'] ){
            case 1:
                return '有';
                break;
            case 0:
                return '无';
                break;
        }
    }

    public function getNumTextAttr($value,$data)
    {
        switch ( $data['num'] ){
            case 'double':
                return '双';
                break;
            case 'single':
                return '单';
                break;
        }
    }
    public function getTypeTextAttr($value,$data)
    {
        switch ( $data['type'] ){
            case 'close':
                return '近战';
                break;
            case 'far':
                return '远程';
                break;
        }
    }




}
